level: any
What is Eddie?
Eddie is a new code editor written in Liberty BASIC, for Liberty BASIC. Eddie can be customized and extended to meet the needs of the individual programmer. The newest version is available here: Eddie!
What is Syntax Coloring?
Syntax coloring causes different code elements to be displayed in unique colors. Quoted strings appear in one color, while comments appear in another color and keywords in yet another color. Operators appear in a separate color.
In CodeAChrome, a line is colored after the user finishes typing it. If he hits ENTER, or clicks on a different line with the mouse, or pages up or down, the line upon which he was typing is sent to the syntax coloring routine. Syntax coloring is not handled as text is typed. It is only accomplished when the text caret is moved to a different line. This is different than the way it is done in the Liberty BASIC editor, where text is colored as it is typed.
Why Use Syntax Coloring?
Syntax coloring makes code easier to read. If comments are displayed in a unique color, they are very easy to find.
Syntax coloring also helps us find errors in code. If we forget to close a quoted string, the text following the string is displayed in the string color, instead of the proper color. We can easily find the beginning of the quoted string and look for the missing quotation mark at the end. If a keyword does not change from the default color to the keyword color, we know that we've misspelled it.
What are Keywords?
Keywords are commands and functions that are native to a computer programming language. Some keywords are nearly universal. These include words like "if", "then", "print", "open", "input" and many others. CodeAChrome has a default set of keywords that appear in blue when syntax coloring is turned on. They are as follows:
abs acs append as asc asn atn beep binary boolean button call case checkbox chr$ close cls combobox cos cursor data date$ def dialog dim dll do dword else elseif end eof err error err$ exit exp field end for function get global gosub goto groupboxp hwnd if inkey$ inp input input$ instr int kill left$ len let line listbox locate loc lof log long loop lower$ lprint max menu mid$ min mod next on open out output playmidi playwave print put radiobutton randomize read redim rem restore resume return right$ rnd run scan seek select shell short sin sort space$ sqr statictext str$ struct sub tab tan textbox then time$ timer trim$ type ulong until upper$ ushort using val void wait wend while window word word$
Liberty BASIC Keywords
We can replace the default keywords in CodeAChrome with Liberty BASIC Keywords. This requires the keywords to be in a string, with words separated by blank spaces. Keywords in CodeAChrome are case insensitive. We set the keywords with a call to SetKeyWords.
calldll #r, "SetKeyWords",_ 'replace keywords with string
keys$ as ptr,_ 'string containing keywords separated by spaces
ret as void 'no return
For version 9, we add the following routine at the beginning of Eddie, after the CodeAChrome DLL has been opened and the control has been created. Notice how we build the string by adding to it over and over again. This method allows us to create a very long string that we can read easily, since it is contained on many lines of code, instead of on a single, very long line.
keys$ = " abs acs append as asc asn atn backgroundcolor$ beep binary bmpbutton bmpsave boolean button call "
keys$ = keys$ + " callback calldll case checkbox chr$ close cls colordialog combobox comboboxcolor$ commandline$ "
keys$ = keys$ + " confirm cos cursor data date$ dechex$ defaultdir$ dialog dialog_fs dialog_modal dialog_nf dialog_nf_modal "
keys$ = keys$ + " dialog_nf_fs dim displayheight displaywidth dll do drives$ dword dump else end eof err error err$ eval "
keys$ = keys$ + " eval$ exit exp field filedialog files fontdialog end for foregroundcolor$ function get gettrim global "
keys$ = keys$ + " gosub goto graphics graphics_fs graphics_fs_nsb graphics_nsb graphics_nf_nsb graphicbox groupbox hbmp "
keys$ = keys$ + " hexdec hwnd if inkey$ inp input input$ inputto$ instr int joy1x joy1y joy1z joy1button1 joy1button2 joy2x "
keys$ = keys$ + " joy2y joy2z joy2button1 joy2button2 kill left$ len let line listbox listboxcolor$ ll loadbmp locate loc "
keys$ = keys$ + " lof log long loop lower$ lprint lr maphandle max menu midipos mid$ min mkdir mod name next nomainwin "
keys$ = keys$ + " notice on open or out output platform$ playmidi playwave popupmenu print printerdialog printerfont$ prompt "
keys$ = keys$ + " ptr put radiobutton randomize read readjoystick redim rem restore resume return right$ rmdir rnd run "
keys$ = keys$ + " scan seek select short sin sort space$ spreadsheet sqr statictext str$ stopmidi struct stylebits sub "
keys$ = keys$ + " tab tan text textbox textboxcolor$ texteditor texteditorcolor$ text_fs text_nsb text_nsb_ins then time$ "
keys$ = keys$ + " timer titlebar trace trim$ txcount ul ulong unloadbmp until upper$ upperleftx upperlefty ur ushort using "
keys$ = keys$ + " val version$ void wait wend while window windowheight windowwidth window_nf winstring word word$ "
calldll #r, "SetKeyWords",_ 'replace keywords with string
keys$ as ptr,_ 'string containing keywords separated by spaces
ret as void 'no return
There's More!
Watch for more features of CodeAChrome in future versions of Eddie.